package com.rzico.sbl.ui.member

import com.rzico.sbl.R
import com.rzico.sbl.databinding.ActivityMemberMoreBinding
import com.rzico.sbl.model.QRType
import com.rzico.sbl.ui.ScanActivity
import com.xinnuo.common.extend.clearTop
import com.xinnuo.common.extend.startActivityEx
import com.xinnuo.common.extend.getExtra
import com.xinnuo.common.extend.oneClick
import com.xinnuo.common_ui.base.BaseActivity

class MemberMoreActivity : BaseActivity(R.layout.activity_member_more) {

    private val mBinding by lazy { ActivityMemberMoreBinding.bind(getRootView()) }

    private lateinit var mCardId: String
    private lateinit var mMemberId: String
    private lateinit var mMemberPhone: String

    override fun initData() {
        initTitle(title = "会员编辑")
    }

    override fun initListener() {
        mCardId = intent.getExtra("cardId")
        mMemberId = intent.getExtra("memberId")
        mMemberPhone = intent.getExtra("memberPhone")

        mBinding.apply {
            // 绑定叫水码
            memberBind.oneClick {
                startActivityEx<ScanActivity>(
                    "mode" to QRType.MEMBER,
                    "from" to "member",
                    "status" to "bind",
                    "memberId" to mMemberId
                )
            }
            // 解绑叫水码
            memberUnbind.oneClick {
                startActivityEx<ScanActivity>(
                    "mode" to QRType.MEMBER,
                    "from" to "member",
                    "status" to "unbind",
                    "memberId" to mMemberId
                )
            }
            // 收货地址
            memberAddr.oneClick {
                startActivityEx<MemberAdressActivity>(
                    "cardId" to mCardId,
                    "memberId" to mMemberId,
                    "memberPhone" to mMemberPhone
                )
            }
            // 消费记录
            memberSpend.oneClick {
                startActivityEx<MemberRecordActivity>(
                    "memberId" to mMemberId
                )
            }
            // 会员推广
            memberShare.oneClick {
                startActivityEx<MemberShareActivity>(
                    "memberId" to mMemberId
                )
            }
            // 商品改价
            memberChange.oneClick {
                startActivityEx<MemberChangeActivity>(
                    "memberId" to mMemberId
                )
            }
            // 优惠券
            memberCoupon.oneClick {
                startActivityEx<MemberCouponActivity>(
                    "cardId" to mCardId
                )
            }
            // 水票管理
            memberTicket.oneClick {
                startActivityEx<MemberTicketActivity>(
                    "cardId" to mCardId,
                    "memberId" to mMemberId
                )
            }
            // 空桶管理
            memberBucket.oneClick {
                startActivityEx<MemberBucketActivity>(
                    "cardId" to mCardId,
                    "memberId" to mMemberId
                )
            }
            // 指定派单
            memberAuto.oneClick {
                startActivityEx<MemberDetailActivity>(
                    "cardId" to mCardId,
                    "memberId" to mMemberId,
                    "memberPhone" to mMemberPhone
                ) { clearTop() }
            }
        }
    }

}